﻿using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for TreatmentManagerTest and is intended
    ///to contain all TreatmentManagerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class TreatmentManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private Treatment LoadTreatment()
        {
            Random random = new Random(DateTime.Now.Millisecond);
            Treatment treatment = new Treatment();
            treatment.CodeDiagnostic = 1;
            treatment.CodeTreatment = 445 + random.Next(10000);
            //treatment.ImageXRay = string.Empty;
            treatment.State = string.Empty;
            return treatment;
        }

        private GeneralTreatment LoadGeneralTreatment()
        {
            Random random = new Random(DateTime.Now.Millisecond);
            GeneralTreatment generalTreatment = new GeneralTreatment();
            //generalTreatment.CodeDiagnostic = 12 + random.Next(10000);
            generalTreatment.CodeTreatment = 54 + random.Next(10000);
            generalTreatment.Description = string.Empty;
            //generalTreatment.DescriptionTreatmentP = string.Empty;
            //generalTreatment.Orthodontics = string.Empty;
            //generalTreatment.TreatmentP = string.Empty;
            generalTreatment.Treatment = string.Empty;
            return generalTreatment;
        }


        private ToothTreatment LoadToothTreatment()
        {
            Random random = new Random(DateTime.Now.Millisecond);
            ToothTreatment toothTreatment = new ToothTreatment();
            //toothTreatment.CodeDiagnostic = 14 + random.Next(10000);
            toothTreatment.CodeTreatment = 124 + random.Next(10000);
            toothTreatment.ToothCode = 125 + random.Next(10000);
            toothTreatment.ToothImage = string.Empty;
            toothTreatment.ToothLocation = string.Empty;
            toothTreatment.ToothType = string.Empty;
            toothTreatment.Treatment = string.Empty;
            toothTreatment.TreatmentDescription = string.Empty;
            return toothTreatment;            
        }

        /// <summary>
        //A test for NewTreatmentPatient
        ///</summary>
        [TestMethod()]
        public void NewTreatmentPatientTest()
        {
            Treatment treatment = LoadTreatment(); // TODO: Initialize to an appropriate value
            GeneralTreatment generalTreatment = LoadGeneralTreatment(); // TODO: Initialize to an appropriate value
            ToothTreatment toothTreatment = LoadToothTreatment(); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = TreatmentManager.NewTreatmentPatient(treatment, generalTreatment, toothTreatment);
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        //A test for NewTreatmentPatient Null
        ///</summary>
        [TestMethod()]
        public void NewTreatmentPatientNullTest()
        {
            Treatment treatment = null; // TODO: Initialize to an appropriate value
            GeneralTreatment generalTreatment = null; // TODO: Initialize to an appropriate value
            ToothTreatment toothTreatment = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = TreatmentManager.NewTreatmentPatient(treatment, generalTreatment, toothTreatment);
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for LoadDataGridViewTreatmentOfTheSelectedAppointment
        ///</summary>
        [TestMethod()]
        public void LoadDataGridViewTreatmentOfTheSelectedAppointmentTest()
        {            
            DataTable actual;
            actual = TreatmentManager.LoadDataGridViewTreatmentOfTheSelectedAppointment();         
            Assert.IsTrue(actual.Rows.Count>=1);            
        }
    }
}
